package com.anXin.article.service.impl;


import com.anXin.article.mapper.CollectMapper;
import com.anXin.article.mapper.LikeMapper;
import com.anXin.article.service.CollectService;
import com.anXin.article.service.LikeService;
import com.anXin.model.article.pojos.Collect;
import com.anXin.model.article.pojos.Like;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import utils.thread.AppThreadLocalUtil;

@Service
public class LikeServiceImpl extends ServiceImpl<LikeMapper, Like> implements LikeService {
    @Override
    public Integer likeCount(Long articleId) {
        Integer count = query().eq("article_id", articleId).count();
        return count;
    }

    @Override
    public Boolean isLike(Long articleId) {
        Like one = query().eq("user_id", AppThreadLocalUtil.getUser().getId()).eq("article_id", articleId).one();

        return one!=null;
    }
}
